package org.c41.reflect;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class NamedInvocationHandler implements InvocationHandler {

	private Object obj;
	
	public NamedInvocationHandler(Object obj){
		this.obj=obj;
	}
	
	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		Method invoke = obj.getClass().getDeclaredMethod(method.getName(), method.getParameterTypes());
		invoke.setAccessible(true);
		return invoke.invoke(obj, args);
	}

}
